/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.core.ui.dialogs;

import org.eclipse.jface.dialogs.IInputValidator;

import com.cea.papyrus.classdiagram.parsers.modelgenerator.ParameterGenerator;
import com.cea.papyrus.umlutils.Parameter;

/**
 * 
 * 
 * @author RS211865
 * Validator for Parameter Labels
 * @see org.eclipse.jface.dialogs.InputDialog
 */
public class ParameterLabelValidator implements IInputValidator {

	/**
	 * 
	 */
	private Parameter parameter;
	
	/**
	 * 
	 * 
	 * @return the parameter
	 */
	public Parameter getParameter() {
		return parameter;
	}

	/**
	 * 
	 * 
	 * @param parameter the parameter to set
	 */
	public void setParameter(Parameter parameter) {
		this.parameter = parameter;
	}
	
	/**
	 * 
	 * 
	 * @param parameter 
	 */
	public ParameterLabelValidator(Parameter parameter) {
		super();
		setParameter(parameter);
	}
	
	/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.IInputValidator#isValid(java.lang.String)
	 */
	/**
	 * 
	 * 
	 * @param newText 
	 * 
	 * @return 
	 */
	public String isValid(String newText) {
		ParameterGenerator generator = new ParameterGenerator(parameter);
		return generator.parseAndValidateParameter(newText);
	}

}
